# -*- coding: utf-8 -*-
#
# File: Facility.py
#
# Copyright (c) 2008 by []
# Generator: ArchGenXML Version 2.1
#            http://plone.org/products/archgenxml
#
# GNU General Public License (GPL)
#

__author__ = """unknown <unknown>"""
__docformat__ = 'plaintext'

from AccessControl import ClassSecurityInfo
from Products.Archetypes.atapi import *
from zope.interface import implements
import interfaces

from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.ATContentTypes.content.document import ATDocument
from Products.ATContentTypes.content.document import ATDocumentSchema
from Products.PloneFacilities.config import *

##code-section module-header #fill in your manual code here
##/code-section module-header

schema = Schema((

    StringField(
        name='title',
        widget=StringField._properties['widget'](
            label="Facility Name",
            label_msgid='PloneFacilities_label_title',
            i18n_domain='PloneFacilities',
        ),
        required=True,
        accessor="Title",
    ),
    ImageField(
        name='image',
        widget=ImageField._properties['widget'](
            label="Image",
            description="A thumbnail of this image will be shown",
            label_msgid='PloneFacilities_label_image',
            description_msgid='PloneFacilities_help_image',
            i18n_domain='PloneFacilities',
        ),
        sizes={'large':(768, 768), 'preview':(400, 400), 'mini':(200, 200), 'thumb':(128, 128), 'tile':(64, 64), 'icon':(32, 32), 'listing':(16, 16)},
        storage=AttributeStorage(),
        max_size=(1280,1280),
        validators=('isNonEmptyFile',),
    ),
    StringField(
        name='locationAddress',
        widget=StringField._properties['widget'](
            label="Street Address",
            label_msgid='PloneFacilities_label_locationAddress',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    StringField(
        name='locationCity',
        default='Raton',
        widget=StringField._properties['widget'](
            label="City",
            label_msgid='PloneFacilities_label_locationCity',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    StringField(
        name='locationState',
        default='NM',
        widget=StringField._properties['widget'](
            label="State",
            maxlength=2,
            size=2,
            label_msgid='PloneFacilities_label_locationState',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    IntegerField(
        name='locationZIP',
        default=87740,
        widget=IntegerField._properties['widget'](
            label="ZIP",
            label_msgid='PloneFacilities_label_locationZIP',
            i18n_domain='PloneFacilities',
        ),
        required=True,
        validators=('isZipCode',),
    ),
    TextField(
        name='embeddableMapCode',
        widget=TextAreaWidget(
            description="Leave blank if you want a map autmatically created for this facility.  Otherwise, paste HTML code for the manually created map you want to be shown.",
            label="Override Automatic Facility Map",
            label_msgid='PloneFacilities_label_embeddableMapCode',
            description_msgid='PloneFacilities_help_embeddableMapCode',
            i18n_domain='PloneFacilities',
        ),
    ),
    LinesField(
        name='hours',
        widget=LinesField._properties['widget'](
            description="Hours of operation for this facility",
            label="Hours",
            label_msgid='PloneFacilities_label_hours',
            description_msgid='PloneFacilities_help_hours',
            i18n_domain='PloneFacilities',
        ),
    ),
    LinesField(
        name='fees',
        widget=LinesField._properties['widget'](
            label="Fees",
            description="Costs for this facility",
            label_msgid='PloneFacilities_label_fees',
            description_msgid='PloneFacilities_help_fees',
            i18n_domain='PloneFacilities',
        ),
    ),
    StringField(
        name='contactPhone',
        default="1-575-",
        widget=StringField._properties['widget'](
            label="Phone",
            description="Contact phone number",
            label_msgid='PloneFacilities_label_contactPhone',
            description_msgid='PloneFacilities_help_contactPhone',
            i18n_domain='PloneFacilities',
        ),
        required=True,
    ),
    StringField(
        name='contactEmail',
        widget=StringField._properties['widget'](
            label="Email",
            description="Contact email address",
            label_msgid='PloneFacilities_label_contactEmail',
            description_msgid='PloneFacilities_help_contactEmail',
            i18n_domain='PloneFacilities',
        ),
        validators=('isEmail',),
    ),
    TextField(
        name='description',
        widget=TextAreaWidget(
            description="A short description of this facility.  It will be displayed in the index of facilities.",
            rows=2,
            label='Description',
            label_msgid='PloneFacilities_label_description',
            description_msgid='PloneFacilities_help_description',
            i18n_domain='PloneFacilities',
        ),
        accessor="Description",
    ),

),
)

##code-section after-local-schema #fill in your manual code here
##/code-section after-local-schema

Facility_schema = ATDocumentSchema.copy() + \
    schema.copy()

##code-section after-schema #fill in your manual code here
##/code-section after-schema

class Facility(ATDocument):
    """
    """
    security = ClassSecurityInfo()

    implements(interfaces.IFacility)

    meta_type = 'Facility'
    _at_rename_after_creation = True

    schema = Facility_schema

    ##code-section class-header #fill in your manual code here
    ##/code-section class-header

    # Methods

def modify_fti(fti):
    # Hide unnecessary tabs (usability enhancement)
    for a in fti['actions']:
        if a['id'] in ['metadata']:
            a['visible'] = 0
    return fti

registerType(Facility, PROJECTNAME)
# end of class Facility

##code-section module-footer #fill in your manual code here
##/code-section module-footer



